package test;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class date {
	
	
	public static boolean year(int year)
	{
		return year%400==0||year%100!=0&&year%4==0;
	}
	public static boolean days(int year,int month,int day)
	{
		if((month==1||month==3||month==5||month==7||month==8||month==10||month==12)&&day<=31)
			return true;
		else if((month==4||month==6||month==9||month==11)&&day<=30)
			return true;
		else if(month==2&&year(year)&&day<=29)
			return true;
		else if(month==2&&!year(year)&&day<=28)
			return true;
		return false;
	}
	public static String reback(String string)
	{
		String ss="";
		char c[]=string.toCharArray();
		for(int i=c.length-1;i>=0;i--)
			ss+=c[i];
		return ss;
	}
	
    public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new FileReader("date.in"));
        BufferedWriter bw = new BufferedWriter(new FileWriter("date.out"));
        String date1="",date2="";
        date1=br.readLine();
        date2=br.readLine();
        String string="";
		char c[]=new char[8];
		int j,k=0;
		for(int i=Integer.parseInt(date1);i<=Integer.parseInt(date2);i++)
		{
			string+=i;
			c=string.toCharArray();
			for(j=0;j<c.length/2;j++)	
				if(c[j]!=c[c.length-1-j])
					break;
			if(j>=c.length/2)
			{
				if(days(Integer.parseInt(string.substring(0,4)),Integer.parseInt(string.substring(4,6)),Integer.parseInt(string.substring(6)))&&days(Integer.parseInt(reback(string).substring(0,4)),Integer.parseInt(reback(string).substring(4,6)),Integer.parseInt(reback(string).substring(6))))
				{
					k++;
				}
			}
			string="";
		}
		bw.write(k+"\r\n");
		//bw.write(date1);
        
        br.close();
        bw.close();
    }
}

